// $ANTLR : "AnasinFLEX.g" -> "AnasinFLEX.java"$

	package pl.equipo13.p5;

import antlr.TokenBuffer;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.ANTLRException;
import antlr.LLkParser;
import antlr.Token;
import antlr.TokenStream;
import antlr.RecognitionException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.ParserSharedInputState;
import antlr.collections.impl.BitSet;

public class AnasinFLEX extends antlr.LLkParser       implements AnasinFLEXTokenTypes
 {

protected AnasinFLEX(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
}

public AnasinFLEX(TokenBuffer tokenBuf) {
  this(tokenBuf,2);
}

protected AnasinFLEX(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
}

public AnasinFLEX(TokenStream lexer) {
  this(lexer,2);
}

public AnasinFLEX(ParserSharedInputState state) {
  super(state,2);
  tokenNames = _tokenNames;
}

	public final void entrada_flex() throws RecognitionException, TokenStreamException {
		
		
		sec_definicion();
		match(SEPARADOR);
		sec_reglas();
		match(SEPARADOR);
		sec_c();
		match(Token.EOF_TYPE);
	}
	
	public final void sec_definicion() throws RecognitionException, TokenStreamException {
		
		
		{
		_loop972:
		do {
			if ((LA(1)==IDENT)) {
				declaracion();
			}
			else {
				break _loop972;
			}
			
		} while (true);
		}
		{
		switch ( LA(1)) {
		case ACODEBLOCK:
		{
			codeblock_def();
			break;
		}
		case SEPARADOR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void sec_reglas() throws RecognitionException, TokenStreamException {
		
		
		{
		_loop979:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				{
				_loop977:
				do {
					switch ( LA(1)) {
					case REFERENCIA:
					{
						reglaOR();
						break;
					}
					case ABRIRPARENTESIS:
					{
						reglaparentesis();
						break;
					}
					default:
					{
						break _loop977;
					}
					}
				} while (true);
				}
				{
				switch ( LA(1)) {
				case IDENT:
				{
					match(IDENT);
					match(INC);
					break;
				}
				case PUNTOCOMA:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
				match(PUNTOCOMA);
			}
			else {
				break _loop979;
			}
			
		} while (true);
		}
	}
	
	public final void sec_c() throws RecognitionException, TokenStreamException {
		
		
		{
		_loop982:
		do {
			if ((_tokenSet_1.member(LA(1)))) {
				funcion();
			}
			else {
				break _loop982;
			}
			
		} while (true);
		}
	}
	
	public final void declaracion() throws RecognitionException, TokenStreamException {
		
		
		match(IDENT);
		match(RANGO);
	}
	
	public final void codeblock_def() throws RecognitionException, TokenStreamException {
		
		
		match(ACODEBLOCK);
		{
		int _cnt986=0;
		_loop986:
		do {
			if ((_tokenSet_1.member(LA(1)))) {
				declaracion_cb();
			}
			else {
				if ( _cnt986>=1 ) { break _loop986; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt986++;
		} while (true);
		}
		match(CCODEBLOCK);
	}
	
	public final void reglaOR() throws RecognitionException, TokenStreamException {
		
		
		reglaAND();
		{
		_loop995:
		do {
			if ((LA(1)==OR)) {
				match(OR);
				reglaAND();
			}
			else {
				break _loop995;
			}
			
		} while (true);
		}
	}
	
	public final void reglaparentesis() throws RecognitionException, TokenStreamException {
		
		
		match(ABRIRPARENTESIS);
		reglaOR();
		match(CERRARPARENTESIS);
		{
		switch ( LA(1)) {
		case ASTERISCO:
		{
			match(ASTERISCO);
			break;
		}
		case MAS:
		{
			match(MAS);
			break;
		}
		case PUNTOCOMA:
		case ABRIRPARENTESIS:
		case IDENT:
		case REFERENCIA:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void funcion() throws RecognitionException, TokenStreamException {
		
		
		tipo_dato();
		match(IDENT);
		match(ABRIRPARENTESIS);
		argumentos();
		match(CERRARPARENTESIS);
		match(ABRIRLLAVE);
		codigo();
		match(CERRARLLAVE);
	}
	
	public final void declaracion_cb() throws RecognitionException, TokenStreamException {
		
		
		tipo_dato();
		match(IDENT);
		match(PUNTOCOMA);
	}
	
	public final void tipo_dato() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case DOUBLE:
		case FLOAT:
		case INT:
		case LONG:
		case SHORT:
		case SIGNED:
		case UNSIGNED:
		{
			{
			{
			switch ( LA(1)) {
			case SIGNED:
			{
				match(SIGNED);
				break;
			}
			case UNSIGNED:
			{
				match(UNSIGNED);
				break;
			}
			case DOUBLE:
			case FLOAT:
			case INT:
			case LONG:
			case SHORT:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			{
			switch ( LA(1)) {
			case INT:
			{
				match(INT);
				break;
			}
			case DOUBLE:
			{
				match(DOUBLE);
				break;
			}
			case FLOAT:
			{
				match(FLOAT);
				break;
			}
			case SHORT:
			{
				match(SHORT);
				break;
			}
			default:
				if ((LA(1)==LONG) && (LA(2)==ASTERISCO||LA(2)==IDENT)) {
					match(LONG);
				}
				else if ((LA(1)==LONG) && (LA(2)==ASTERISCO||LA(2)==IDENT)) {
					match(LONG);
				}
			else {
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			}
			break;
		}
		case CHAR:
		{
			match(CHAR);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void reglasimple() throws RecognitionException, TokenStreamException {
		
		
		match(REFERENCIA);
		{
		switch ( LA(1)) {
		case ASTERISCO:
		{
			match(ASTERISCO);
			break;
		}
		case MAS:
		{
			match(MAS);
			break;
		}
		case PUNTOCOMA:
		case ABRIRPARENTESIS:
		case CERRARPARENTESIS:
		case OR:
		case IDENT:
		case REFERENCIA:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void reglaAND() throws RecognitionException, TokenStreamException {
		
		
		{
		int _cnt992=0;
		_loop992:
		do {
			if ((LA(1)==REFERENCIA) && (_tokenSet_2.member(LA(2)))) {
				reglasimple();
			}
			else {
				if ( _cnt992>=1 ) { break _loop992; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt992++;
		} while (true);
		}
	}
	
	public final void argumentos() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case VOID:
		{
			match(VOID);
			break;
		}
		case CHAR:
		case DOUBLE:
		case FLOAT:
		case INT:
		case LONG:
		case SHORT:
		case SIGNED:
		case UNSIGNED:
		case COMA:
		case CERRARPARENTESIS:
		{
			{
			_loop1004:
			do {
				if ((_tokenSet_3.member(LA(1)))) {
					{
					switch ( LA(1)) {
					case COMA:
					{
						match(COMA);
						break;
					}
					case CHAR:
					case DOUBLE:
					case FLOAT:
					case INT:
					case LONG:
					case SHORT:
					case SIGNED:
					case UNSIGNED:
					{
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
					tipo_dato();
					{
					switch ( LA(1)) {
					case ASTERISCO:
					{
						match(ASTERISCO);
						break;
					}
					case IDENT:
					{
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
					match(IDENT);
					{
					switch ( LA(1)) {
					case ABRIRCORCHETE:
					{
						match(ABRIRCORCHETE);
						match(CERRARCORCHETE);
						break;
					}
					case CHAR:
					case DOUBLE:
					case FLOAT:
					case INT:
					case LONG:
					case SHORT:
					case SIGNED:
					case UNSIGNED:
					case COMA:
					case CERRARPARENTESIS:
					{
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
				}
				else {
					break _loop1004;
				}
				
			} while (true);
			}
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void codigo() throws RecognitionException, TokenStreamException {
		
		
		{
		_loop1007:
		do {
			if ((LA(1)==IDENT) && (LA(2)==IGUAL)) {
				asignacion();
			}
			else if ((LA(1)==IDENT) && (LA(2)==ABRIRPARENTESIS)) {
				func();
				match(PUNTOCOMA);
			}
			else {
				break _loop1007;
			}
			
		} while (true);
		}
		match(RETURN);
		match(NUMERO);
		match(PUNTOCOMA);
	}
	
	public final void asignacion() throws RecognitionException, TokenStreamException {
		
		
		match(IDENT);
		match(IGUAL);
		{
		switch ( LA(1)) {
		case NUMERO:
		{
			match(NUMERO);
			break;
		}
		case IDENT:
		{
			func();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(PUNTOCOMA);
	}
	
	public final void func() throws RecognitionException, TokenStreamException {
		
		
		match(IDENT);
		match(ABRIRPARENTESIS);
		{
		_loop1015:
		do {
			if ((LA(1)==CADENA||LA(1)==COMA||LA(1)==IDENT)) {
				{
				switch ( LA(1)) {
				case COMA:
				{
					match(COMA);
					break;
				}
				case CADENA:
				case IDENT:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
				{
				switch ( LA(1)) {
				case IDENT:
				{
					match(IDENT);
					{
					switch ( LA(1)) {
					case ARRAY:
					{
						match(ARRAY);
						break;
					}
					case CADENA:
					case COMA:
					case CERRARPARENTESIS:
					case IDENT:
					{
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
					}
					break;
				}
				case CADENA:
				{
					match(CADENA);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
			}
			else {
				break _loop1015;
			}
			
		} while (true);
		}
		match(CERRARPARENTESIS);
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"\"auto\"",
		"\"break\"",
		"\"CASE\"",
		"\"char\"",
		"\"const\"",
		"\"continue\"",
		"\"default\"",
		"\"do\"",
		"\"double\"",
		"\"else\"",
		"\"enum\"",
		"\"extern\"",
		"\"float\"",
		"\"for\"",
		"\"goto\"",
		"\"if\"",
		"\"int\"",
		"\"long\"",
		"\"register\"",
		"\"return\"",
		"\"short\"",
		"\"signed\"",
		"\"sizeof\"",
		"\"static\"",
		"\"struct\"",
		"\"switch\"",
		"\"typedef\"",
		"\"union\"",
		"\"unsigned\"",
		"\"void\"",
		"\"volatile\"",
		"\"while\"",
		"NUEVA_LINEA",
		"BLANCO",
		"ACOMENTARIO",
		"CCOMENTARIO",
		"COMENTARIOBARRA",
		"COMILLAS",
		"COMENTARIO",
		"COMENTARIO2",
		"CADENA",
		"DIGITO",
		"LETRA",
		"PORCENTAJE",
		"GUIONBAJO",
		"GUION",
		"PUNTO",
		"PUNTOCOMA",
		"COMA",
		"ABRIRCORCHETE",
		"CERRARCORCHETE",
		"ABRIRLLAVE",
		"CERRARLLAVE",
		"ABRIRPARENTESIS",
		"CERRARPARENTESIS",
		"IGUAL",
		"OR",
		"ASTERISCO",
		"MAS",
		"INC",
		"ACODEBLOCK",
		"CCODEBLOCK",
		"SEPARADOR",
		"IDENT",
		"NUMERO",
		"DEFRANGO",
		"RANGO",
		"REFERENCIA",
		"ARRAY"
	};
	
	private static final long[] mk_tokenSet_0() {
		long[] data = { 146366987889541120L, 136L, 0L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = { 4348514432L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	private static final long[] mk_tokenSet_2() {
		long[] data = { 8505047896289181696L, 136L, 0L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
	private static final long[] mk_tokenSet_3() {
		long[] data = { 4503603975884928L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
	
	}
